# Maintainer: Sergej Pupykin <arch+pub@sergej.pp.ru>
# Maintainer: Daniel Nagy <danielnagy at gmx de>

pkgname=haskell-entropy
pkgver=0.4.1.10
pkgrel=1
pkgdesc="A mostly platform independent (not GHCJS) method to obtain cryptographically strong entropy"
url="https://hackage.haskell.org/package/entropy"
license=('BSD')
arch=('loong64' 'x86_64')
depends=('ghc-libs')
makedepends=('ghc')
source=(https://hackage.haskell.org/packages/archive/entropy/${pkgver}/entropy-${pkgver}.tar.gz)
sha512sums=('521dded7ae41cc532993236d0ced394f98f495c0c8950201064d17430ee6599d9cd6f3a4f17a19429396ee4a34a3fa17b39af49f4fee730efdae3d42d134c96e')

build() {
    cd "${srcdir}/entropy-${pkgver}"
    
    runhaskell Setup configure -O --enable-shared --enable-executable-dynamic --disable-library-vanilla \
        --prefix=/usr --docdir=/usr/share/doc/$pkgname --datasubdir=$pkgname \
        --dynlibdir=/usr/lib --libsubdir=\$compiler/site-local/\$pkgid --ghc-option=-fllvm
    runhaskell Setup build $MAKEFLAGS
    runhaskell Setup register --gen-script
    runhaskell Setup unregister --gen-script
    sed -i -r -e "s|ghc-pkg.*update[^ ]* |&'--force' |" register.sh
    sed -i -r -e "s|ghc-pkg.*unregister[^ ]* |&'--force' |" unregister.sh
}

package() {
    cd "${srcdir}/entropy-${pkgver}"
    
    install -D -m744 register.sh "$pkgdir"/usr/share/haskell/register/$pkgname.sh
    install -D -m744 unregister.sh "$pkgdir"/usr/share/haskell/unregister/$pkgname.sh
    runhaskell Setup copy --destdir="$pkgdir"
    install -D -m644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
    rm -f "$pkgdir"/usr/share/doc/$pkgname/LICENSE
}
